package com.tuzhi.common.constants;

import java.util.Objects;

public interface ResultConstant {

    RC SUCCESS = new RC("0", "成功");
    RC ERROR = new RC("99999", "异常");

    // ---------------参数异常
    RC ERR_PARAM = new RC("P0001", "参数异常");
    RC ERR_PARAM_NULL = new RC("P0002", "参数为空");
    RC ERR_TOKEN_NULL = new RC("P0003", "token为空");
    RC ERR_TOKEN_ERR = new RC("P0004", "token无效");
    RC ERR_PARAM_4UPDATE = new RC("P0005", "转入参数为空，或是主键为空，修改必须主键有值");


    // ---------------业务异常
    RC ERR_BUSINESS = new RC("B0001", "业务异常");
    RC ERR_NOT_PERMISSION = new RC("B0002", "没有权限");
    RC ERR_ENTITY_NONEXIS = new RC("B0003", "记录不存在");


    // ---------------系统异常
    RC ERR_SYS = new RC("S0001", "系统异常");
    RC ERR_AUTH_SYS = new RC("S0002", "登录超时,请重新登录!");

    // ---------------外部异常
    RC ERR_EXTERNAL = new RC("E0001", "外部异常");

    // ---------------其他异常
    RC ERR_OTHER = new RC("O0001", "其他异常");







    public static class RC{
        String code;
        String msg;

        public RC(String code, String msg) {
            this.code = code;
            this.msg = msg;
        }

        public String getCode() {
            return code;
        }

        public String getMsg() {
            return msg;
        }

        @Override
        public boolean equals(Object o) {
            if (this == o) return true;
            if (o == null || getClass() != o.getClass()) return false;
            RC rc = (RC) o;
            return Objects.equals(code, rc.code);
        }

        @Override
        public int hashCode() {

            return Objects.hash(code);
        }

        @Override
        public String toString() {
            return "RC{" +
                    "code='" + code + '\'' +
                    ", msg='" + msg + '\'' +
                    '}';
        }
    }

}
